package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/edge"
	"entgo.io/ent/schema/field"

	cent "gitee.com/shuokeyun/common/ent"
)

type OrderUser struct {
	ent.Schema
}

func (OrderUser) Mixin() []ent.Mixin {
	return []ent.Mixin{
		cent.OrmMixin{},
	}
}

func (OrderUser) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.Annotation{
			Table: "sk_order_user",
		},
	}
}

func (OrderUser) Fields() []ent.Field {
	return []ent.Field{
		field.Int64("order_id").Comment("订单id"),
		field.Int64("barcode_id").Immutable().Comment("条码id"),
		field.Int64("user_id").Immutable().Comment("用户id"),
		field.String("name").Comment("姓名"),
		field.Int16("age").Comment("年龄"),
		field.Int8("sex").Comment("性别1男2女"),
		field.String("mobile").Comment("手机"),
		field.Int8("card_type").Comment("证件类型1身份证2护照"),
		field.String("card_id").Comment("证件号"),
	}
}

func (OrderUser) Edges() []ent.Edge {
	return []ent.Edge{
		edge.From("order", Order.Type).Ref("users").Unique().Required().Field("order_id"),
	}
}
